Object-relational mapping can be used to convert data between an object model of an object-oriented program and a relational database. The mapping is performed, at least in part, by a tool known as an object-relational mapper. The acronym ORM is used herein to denote the mapping tool, the mapping itself, or both.
An ORM is useful because data in the object model is organized in non-scalar items, whereas data in the relational database is organized in scalar items. Integers, floating point values, and strings are examples of scalar values; structs, records, and object instances are examples of non-scalar values. An object model includes objects (class instances) which are frequently non-scalar values. In addition to multiple associated data values, an object may have associated methods, such as methods to set or get the data values or perform other operations. Many familiar database systems, including many structured query language database management systems, store and manipulate only scalar values, which are organized within tables. An ORM helps convert object values into groups of scalar values for storage in the database, and convert those scalar values back into objects upon retrieval from the database. Thus, an ORM helps translate a logical representation of objects into a form that can be stored in a database, without losing track of object properties and inter-relationships.